<?php
//判断是否登陆
function is_adm_login()
{
    $a = session('uid');
    return empty($a) ? 0 : session('uid');
}

/**
 * [toDate description]
 * @param  [type] $time   [日期字符串]
 * @param  string $format [时间格式]
 * @return [type]         [返回日期]
 */
function toDate($time, $format = 'Y-m-d H:i:s') {
	if (empty ( $time )) {
		return '';
	}
	$format = str_replace ( '#', ':', $format );
	return date ($format, $time );
}
/**
 * [getStatus 获取当前状态]
 * @param  [type]  $status    [标识当前状态的数值]
 * @param  boolean $imageShow [返回图片或文字]
 * @return [type]             [返回值]
 */
function getStatus($status, $imageShow = true) {
	switch ($status) {
		case 0 :
			$showText = '禁用';
			$showImg = '<IMG SRC="'.__APP__.'/Public/Images/locked.gif" WIDTH="20" HEIGHT="20" BORDER="0" ALT="禁用" />';
			break;
		case 1 :
		default :
			$showText = '正常';
			$showImg = '<IMG SRC="'.__APP__.'/Public/Images/ok.gif" WIDTH="20" HEIGHT="20" BORDER="0"" ALT="正常" />';

	}
	return ($imageShow == true) ?  $showImg  : $showText;
}

function changeStatus($status, $id, $callback="", $M,$C, $dwz) {
	switch ($status) {
		case 0 :
			$info = '<a href="'.U($M.'/'.$C.'/sStatus','','').'/id/' . $id . '/navTabId/'.$dwz.'" target="ajaxTodo" callback="'.$callback.'">恢复</a>';
			break;
		case 1 :
			$info = '<a href="'.U($M.'/'.$C.'/dStatus','','').'/id/' . $id . '/navTabId/'.$dwz.'" target="ajaxTodo" callback="'.$callback.'">禁止</a>';
			break;
		case - 1 :
			$info = '<a href="'.$M.'/recycle/id/' . $id . '/navTabId/'.$dwz.'" target="ajaxTodo" callback="'.$callback.'">还原</a>';
			break;
	}
	return $info;
}

function array_sort($array,$row){
	$array_temp = array();
	foreach($array as $k=>$v){
		foreach ($row as $vv) {
			$array_temp[$k][$vv]=$v[$vv];
		}			
		//$array_temp[$v[$row]] = $v;
	}
	return $array_temp;
}